# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=sulley
pkgver=1.0.bff0dd1
pkgrel=3
epoch=4
groups=('blackarch' 'blackarch-fuzzer')
pkgdesc='A pure-python fully automated and unattended fuzzing framework.'
arch=('any')
url='https://github.com/OpenRCE/sulley/'
license=('GPL2')
makedepends=('git')
depends=('python2' 'libpcap' 'python2-pcapy' 'impacket')
source=("git+http://github.com/OpenRCE/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  # Grabbing major-version from install script
  printf "%s.%s" \
    $(grep -i 'define PRODUCT_VERSION' installer/Nullsoft\ Installer\ Script.nsi | cut -d'"' -f2) \
    "$(git rev-parse --short HEAD)"
}

prepare() {
  cd $pkgname

  grep -iRl '/usr/bin/python' "$srcdir/sulley" |
  xargs sed -i 's|#!.*/usr/bin/python$|#!/usr/bin/python2|'
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/share/$pkgname"

  cp -a --no-preserve=ownership * "$pkgdir/usr/share/$pkgname/"
}

